package com.tjnu.losca.controller;


import com.tjnu.losca.Vo.ResponseVO;
import com.tjnu.losca.form.OrderManager;
import com.tjnu.losca.service.IOrdeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author losca
 * @since 2022-02-16
 */
@RestController
@RequestMapping("/order")
public class OrdeController {
    @Autowired
    IOrdeService orderService;
    @GetMapping("/getOrders")
    public ResponseVO<List<OrderManager>> getUsers(@RequestParam(defaultValue = "1") int pageNum,
                                                   @RequestParam(defaultValue = "8") int pageSize,
                                                   @RequestParam(defaultValue = "") String search)  {
        return ResponseVO.success(orderService.list(pageNum, pageSize, search));
    }
    @PostMapping("/del")
    public ResponseVO<Boolean> del(String orderNo){
        return ResponseVO.success(orderService.del(orderNo));
    }

    @PostMapping("/rec")
    public ResponseVO<Boolean> rec(String orderNo){
        System.out.println(orderNo);
        return ResponseVO.success(orderService.rec(orderNo));
    }
    @PostMapping("/mulDel")
    public ResponseVO<Boolean> mulDel(String[] orderNos){
        return ResponseVO.success(orderService.mulDel(orderNos));
    }

    @GetMapping("/sendGood")
    public ResponseVO<Boolean> sendGood(String orderNo){
        return ResponseVO.success(orderService.sendGood(orderNo));
    }


}
